package com.qf.game;
//怎样让英雄使用武器  给类加一个武器属性
public class Hero {
    private  Weapon weapon;
    //英雄拥有的武器
    private int power;
    //力量属性
    public Hero() {
    }

    public Weapon getWeapon() {
        return weapon;
    }

    public void setWeapon(Weapon weapon) {
        this.weapon = weapon;
    }


    public Hero( Weapon weapon, int power) {
        this.weapon = weapon;
        this.power = power;
    }

    public int getPower() {
        return power;
    }

    public void setPower(int power) {
        this.power = power;
    }
    public void attack(){
        if (weapon==null){
            System.out.println("徒手造成的伤害值为："+power);
        }else{
            int weaponDamage = this.weapon.dealDamage();
            int totalDamage = this.power +weaponDamage;
            System.out.println(weapon.getName()+"造成的伤害值为："+totalDamage);
        }
//
    }

}
